package com.shopoo.oauth.wap.runner;

import javax.annotation.Resource;

import com.shopoo.oauth.api.RoleService;
import com.shopoo.oauth.domain.repository.MsgRepository;
import lombok.extern.slf4j.Slf4j;

import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @Description: 初始化服务
 * @Auther: limy66
 * @Date: 2021/04/23/9:22
 */
@Component
@Slf4j
public class Runner implements CommandLineRunner {

    @Resource
    private RoleService roleService;

    @Resource
    private MsgRepository msgRepository;

    /**
     * @Description: 缓存所有的角色权限并发通知通知客户端更新权限信息
     * @Author: limy66
     * @Date:   2021/4/23 9:26
     * @Param:  [args]
     * @Return: void
     */
    @Override
    public void run(String... args) throws Exception {
        log.info("缓存所有角色的权限到Redis");
        roleService.cacheAllRoleMenus();
        msgRepository.sendUpdatePermission();
    }
}
